package com.shop.core;

import lombok.Getter;

@Getter
public enum ResultCode {
    SUCCESS(200, "请求成功"),
    FAILED(500, "系统资源异常");
    private final Integer code;

    private final String message;

    ResultCode(int code, String messahe) {
        this.code = code;
        this.message = messahe;
    }

    public Integer getCode() {
        return code;
    }

    public String getMessage() {
        return message;
    }

    public static ResultCode getValue(String code){
        for (ResultCode value : values()) {
            if (value.getCode().equals(code)) {
                return value;
            }
        }
        return FAILED;
    }
}
